<?php
/**
 * Created by PhpStorm.
 * User: XYX
 * Date: 2017/8/26
 * Time: 16:41
 */

namespace App\Transform;


use App\Comment;
use App\Consumer;

class TwitterCommentsTransform extends Transformer
{
    protected $replyTransform;
    public function __construct(TwitterReplyTransform $replyTransform)
    {
        $this->replyTransform = $replyTransform;
    }
    public function transFrom($item)
    {
        // TODO: Implement transFrom() method.
        return
            [
                "id"=>$item['id'],
                "content"=>$item['content'],
                "consumer_name"=>Consumer::findOrFail($item['comment_consumer_id'])->nickname,
                "replies"=>$this->replyTransform->transformCollect(Comment::findOrFail($item['id'])->replies),
                "date"=>$item['created_at']->toFormattedDateString(),
            ];
    }
}